<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-calendar"></i>财务管理</el-breadcrumb-item>
                <el-breadcrumb-item>兑换审核</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

		<div class="container">
			<el-row>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
					<el-form ref="form" :model="form" label-width="100px">

                        <el-form-item label="兑换订单ID">
                        	<el-input v-model="form.id" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="会员ID">
                        	<el-input v-model="form.member_id" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="转换的金额">
                        	<el-input v-model="form.from_money" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="转换后的金额">
                        	<el-input v-model="form.to_money" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="转换类型">
                        	<el-input v-model="form.from_type" :disabled="true" :value="typeNames[form.from_type]"></el-input>
                        </el-form-item>
                        <el-form-item label="转换后的类型">
                        	<el-input v-model="form.to_type" :disabled="true" :value="typeNames[form.to_type]"></el-input>
                        </el-form-item>
                        <el-form-item label="转换类型的价格">
                        	<el-input v-model="form.price1" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="转换后的类型的价格">
                        	<el-input v-model="form.price2" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="手续费">
                        	<el-input v-model="form.fee" :disabled="true" value="form.fee"></el-input>
                        </el-form-item>
					    <el-form-item label="兑换状态">
					    	<el-select v-model="form.state">
					            <el-option
					                v-for="(name,index) in stateArr"
					                :label="name"
					                :value="index"
					                :key="index"
					            ></el-option>
					        </el-select>
					    </el-form-item>

						<el-form-item label="登录密码">
							<el-input v-model="form.loginpwd" placeholder="登录密码" ></el-input>
						</el-form-item>

					    <el-form-item label="">
					        <el-button :loading="ifload" type="primary" @click="saveData">保存</el-button>
					    </el-form-item>

					</el-form>
				</el-col>
			</el-row>
		</div>

		<loading :ifload="ifload"></loading>
	</div>
</template>

<script type="text/javascript">
	import loading from '@/components/utils/loading';
	export default{
		components:{loading},
		data() {
			return {
				ifload:true,

                id:'',
                typeNames:[],
                stateArr:['通过','审核中','驳回'],

				form:{
                    loginpwd: '',
                    state: '1',
                },
			}
		},
		created() {
            this.id = this.$route.query.id;
			this.$nextTick(()=>{
				this.getData();
			})
		},
		methods: {
			getData() {
                this.ifload = true;
                let param = {id:this.id};
                this.$post_('finance/exchange/exchange-info',param,(res) => {
                    console.log(res);
                    if(res.code=='0'){
                        this.form = res.data
                        this.form.state = res.data.state-1
                        this.typeNames = res.extend.type_name
                    }
                })
				this.ifload = false;
			},
            //保存数据
            saveData() {
                if(this.form.state=='1'){
                    return this.$message.error('状态未修改');
                }
                this.ifload = true;
                this.form.id = this.id;
                this.$post_('finance/exchange/exchange-edit',{id:this.id,state:this.form.state+1,loginpwd:this.form.loginpwd},(res) =>{
                    console.log(res);
                    this.ifload = false;
                    if(res.code=='0'){
                        this.$message.success(res.msg);
                        this.$router.back(-1);
                    }else{
                        this.$message.error(res.msg);
                    }
                })
            }
		}
	}
</script>

<style scoped="scoped">
</style>
